import QtQuick 1.1
//import com.nokia.symbian 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.1
import "platform.js" as PLATFORM
import NumismatMobile 1.0

Page {
    onStatusChanged: {
        if (status === PageStatus.Active || status === PageStatus.Activating) {
            statusBar.text = qsTr("Settings");
            if (PLATFORM.TYPE === "symbian") {
                radio1.platformInverted = true;
                radio2.platformInverted = true;
            }
        }
        if (status === PageStatus.Active) {
            if (PLATFORM.TYPE === "symbian")
                settingsChangingWarning.open();
            else
                settingsChangingWarning.show();
        }
    }

    Rectangle {
        anchors.fill: parent
        color: visual.colorBackgrond
    }

    InfoBanner {
        id: settingsChangingWarning
        anchors.bottom: PLATFORM.TYPE === "harmattan" ? parent.bottom : undefined
        text: qsTr("To apply the changes, you must restart the application");
    }

    Item {
        anchors.top: PLATFORM.TYPE === "harmattan" ? viewHeader.bottom : parent.top
        anchors.bottom: parent.bottom
        anchors.margins: visual.defaultMargin

        Column {
            spacing: 5
            anchors.margins: visual.defaultMargin

            Text {
                id: viewTitle
                text: qsTr('Filter on title works by')
                font.pixelSize: visual.fontLarge
                font.bold: true
                color: visual.colorForeground
            }

            RadioButton {
                id: radio1
                text: qsTr('Country')
                checked: coinModel.view === CoinModel.CommemorativeWorld
                onCheckedChanged: {
                    radio2.checked = !checked;
                }
            }
            RadioButton {
                id: radio2
                text: qsTr('Series')
                checked: coinModel.view === CoinModel.CommemorativeCountry
                onCheckedChanged: {
                    radio1.checked = !checked;
                }
            }
        }
    }

    ViewHeader {
        id: viewHeader
        clickable: false
        visible: PLATFORM.TYPE === "harmattan"
        titleText: qsTr("Settings")
    }

    tools: ToolBarLayout {
        ToolIcon {
            platformIconId: "toolbar-back"
            onClicked: {
                if (radio1.checked)
                    coinModel.view = CoinModel.CommemorativeWorld;
                else if (radio2.checked)
                    coinModel.view = CoinModel.CommemorativeCountry;
                pageStack.pop()
            }
        }
    }
}
